<div style="text-align: center">
    <div style="margin-bottom: 50px">
        <h1 onclick="ApiTestObj.html()"><button>接口测试</button></h1>
    </div>

    <div class="api_test_area_div">

    </div>
    <script>
        let ApiTestObj = {
            html: function () {
                let url = '/webautocode/apimanage/testapi';

                let tablename='{$tablename}';//表
                //查询条件字段
                let condition_field = $('input:checkbox[name="condition_field"]:checked').map(function(){
                    return $(this).val();
                }).get().join(',');


                //接口域名
                let api_domain = $('.api_domain').val();
                if(!api_domain){
                    return layer.msg('请填写接口测试域名');
                }
                let api_controller_name = $('.api_controller_name').val();
                if(!api_controller_name){
                    return layer.msg('请指定接口控制器名');
                }

                let api_name = $('.api_name').val();
                if(!api_name){
                    return layer.msg('请指定接口名');
                }

                //接口描述
                let api_desc = $('.api_desc').val();


                let data = {
                    tablename:tablename,
                    condition_field:condition_field,
                    api_domain:api_domain,
                    api_controller_name:api_controller_name,
                    api_name:api_name,
                    api_desc:api_desc,

                };
                $.post(url,data,function (res) {
                    $('.api_test_area_div').html(res.data);

                },'json');
            }
        };

    </script>
    <script>
        let ApiTestFormObj = {
            test: function (){
                let url = '/webautocode/Apimanage/testapicurl';
                let api_url = $('.api_test_form').attr('action');
                let post_data = $('.api_test_form').serializeArray();
                let pdata = {
                    api_url:api_url,
                    post_data:post_data?post_data:'',
                };
                // return;
                // let data = [];
                // post_data.each(function (a,b){
                //     // data.push({name:b.name,val:})
                // })

                // post_data.api_url = api_url;
                console.log(pdata);

                $.post(url,pdata,function (res) {
                    //把请求结果显示在div中
                    $('.request_test_res').html(res.data);

                },'json');

            }
        };
    </script>
</div>